#ifndef MYEEPROM_H
#define MYEEPROM_H

#include <Arduino.h>
#include <EEPROM.h>

/**
 * @brief WIFI配置 stassid-WIFI名 stapsw-WIFI密码
 *
 */
struct WifiConfigStructure
{
    char stassid[32]; //定义配网得到的WIFI名长度(最大32字节)
    char stapsw[64];  //定义配网得到的WIFI密码长度(最大64字节)
};

class MyEEPROM
{
    public:
        WifiConfigStructure wifiConf;     /* wifi信息 */
        uint8_t updateWeatherTime = 10;    //天气更新时间  X 分钟
        uint8_t scrollInterval = 2;      // 滚动条滚动间隔
        uint8_t animateFrameRate = 20;    // 动画帧率
        uint8_t LCD_Rotation = 0;         // LCD屏幕方向
        uint8_t LCD_BL_PWM = 50;          //屏幕亮度0-100，默认50
        uint32_t cityCodeNum = 101090609;

        MyEEPROM();
        uint8_t readLCDBacklightConfig();
        uint8_t readLCDRotationConfig();
        uint8_t readUpadteWeatherTimeConfig();
        uint8_t readScrollIntervalConfig();
        uint8_t readAnimateFrameRateConfig();
        uint32_t readCityConfig();
        WifiConfigStructure readWIFIConfig();

        void saveLCDBacklightConfig(uint8_t LCDBackLight);
        void saveLCDRotationConfig(uint8_t LCDRotation);
        void saveUpdateWeatherTimeConfig(uint8_t updateWeatherTime);
        void saveScrollIntervalConfig(uint8_t scrollInterval);
        void saveAnimateFrameRateConfig(uint8_t animateFrameRate);
        void saveCityConfig(uint32_t cityCode);
        void saveWIFIConfig(WifiConfigStructure *wifiConfig);
        void deletewificonfig();


    private:
        uint8_t _BL_addr = 1; //被写入数据的EEPROM地址编号  1亮度
        uint8_t _Ro_addr = 2; //被写入数据的EEPROM地址编号  2 旋转方向
        uint8_t _update_weather_time_addr = 3;
        uint8_t _scroll_interval_addr = 4;
        uint8_t _animate_frame_rate_addr = 5;
        uint32_t _CC_addr = 10;   //被写入数据的EEPROM地址编号  10城市
        uint16_t _wifi_addr = 30; //被写入数据的EEPROM地址编号  20wifi-ssid-psw
};

#endif
